package com.starry.module.system.core.oauth2.mapper;

import com.starry.db.core.mapper.BaseMapperX;
import com.starry.db.core.query.LambdaQueryWrapperX;
import com.starry.module.system.core.oauth2.entity.Oauth2ThirdUser;
import org.apache.ibatis.annotations.Mapper;

/**
 * 第三方用户绑定关联-数据库服务层
 *
 * @author xiaoke
 */
@Mapper
public interface Oauth2ThirdUserMapper extends BaseMapperX<Oauth2ThirdUser> {


    /**
     * 根据 openid、第三方类型、用户类型 查询
     *
     * @param openid    openid
     * @param thirdType 第三方类型
     * @param userType  用户类型
     * @return Oauth2ThirdUser
     */
    default Oauth2ThirdUser selectOne(String openid, String thirdType, Integer userType) {
        return selectOne(new LambdaQueryWrapperX<Oauth2ThirdUser>()
                .eq(Oauth2ThirdUser::getOpenid, openid)
                .eq(Oauth2ThirdUser::getUserType, userType)
                .eq(Oauth2ThirdUser::getThirdType, thirdType)
        );
    }
}

